<template>
  <div id="app">
    <h2>测试题</h2>
    <my-subject
      v-for="(item, index) in arr"
      :key="index"
      :item="item"
      @tijiao="item.result = $event"
    ></my-subject>
    <div>
      <my-flag v-for="(item, index) in arr" :key="index" :item="item" :index="index"></my-flag>
    </div>
  </div>
</template>

<script>
import MySubject from "./components/my-subject";
import MyFlag from "./components/my-flag";
export default {
  components: {
    MySubject,
    MyFlag,
  },
  data() {
    return {
      arr: [],
    };
  },
  created() {
    const arr = [];
    for (let i = 0; i < 5; i++) {
      const left = Math.floor(Math.random() * 11);
      const right = Math.floor(Math.random() * 11);
      arr.push({ left, right, result: null });
    }
    this.arr = arr;
  },
};
</script>

<style>
body {
  background-color: #eee;
}

#app {
  background-color: #fff;
  width: 500px;
  margin: 50px auto;
  box-shadow: 3px 3px 3px rgba(0, 0, 0, 0.5);
  padding: 2em;
}
</style>
